<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改任务')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-flow-add" th:object="${work}">
            <input name="workId" th:field="*{workId}" type="hidden">
            <input name="distId" th:value="${work.id}" type="hidden">
            <input name="dealId" th:value="${work.distId}"  type="hidden">
            <input name="dealName" th:value="${work.distName}" type="hidden">
            <input name="level" value="1" type="hidden">
            <input name="currentStatus" th:value="${work.status}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">标题：</label>
                <div class="col-sm-8">
                    <span name="title" th:text="*{title}" class="form-control" type="text" ></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">等级：</label>
                <div class="col-sm-8">
                    <!--<input name="grade" th:field="*{grade}" class="form-control" type="text">-->
                    <select name="grade" class="form-control m-b" th:field="*{grade}" th:with="type=${@dict.getType('tb_work_grade')}" disabled="disabled" >
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group ">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <span name="startTime" th:text="${work.startTime}" class="form-control" type="text" ></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">截至时间：</label>
                <div class="col-sm-8">
                    <div class="input-group ">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <span name="endTime" th:text="${work.endTime}" class="form-control" ></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">说明：</label>
                <div class="col-sm-8">
                    <span name="introduce" class="form-control" th:text="*{introduce}" style="height: 40px;"></span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">创建人：</label>
                <div class="col-sm-8">
                    <span id="userName" name="userName" th:text="*{userName}" class="form-control"></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8">
                    <span id="userTime" name="userTime"  th:text="${#dates.format(work.userTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" ></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">分配给：</label>
                <div class="col-sm-8">
                    <span id="distName" name="distName" th:text="*{distName}" class="form-control"></span>
                </div>
            </div>

            <h4 class="form-header h4">审核流程</h4>
            <div class="row" style="margin: 10px;">
                <h2 style="text-align: center;color: red">审核处理</h2>
            </div>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态：</label>
                    <div class="col-sm-8">
                        <input id="status" th:value="*{status}" class="form-control" type="hidden"/>
                        <span id="statusStr"  class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label">处理流程：</label>
                    <div class="col-sm-8 ">
                        <div class="form-control">
                            <span  name="distName" th:text="'执行人执行('+*{distName}+')'" ></span>
                            -> <span  name="userName" th:text="'提交人验证('+*{userName}+')'" ></span>
                        </div>

                    </div>
                </div>
            </div>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label"><span style="color: red">*</span>处理动作：</label>
                    <div class="col-sm-8">

                        <div class="radio-box" th:each="dict : ${@dict.getType('tb_deal_status')}">
                            <input type="radio" th:id="${dict.dictCode}"  id="dealStatus" name="dealStatus" th:value="${dict.dictValue}"  th:checked="${dict.isDefault == 'Y' ? true : false}">
                            <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>
            </div>
            <input name="actionName" value="执行人执行" type="hidden">

            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label">说明：</label>
                    <div class="col-sm-8">
                       <textarea id="dealExplain" name="dealExplain" rows="5" class="form-control"></textarea>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label"> </label>
                    <div class="col-sm-8">
                        <button class="btn btn-danger" id="btn" type="button" onclick="submitForm()">提交处理</button>
                    </div>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "module/flow"
        $("#form-work-edit").validate({
            focusCleanup: true
        });

        $(function () {
            var value = $("#status").val();
            var distName = $("#distName").html();
            var userName = $("#userName").html();
            var str="";
            if(value=='1'){
                str="待 "+ "<span style='color: red'>"+distName+"</span>" +" 执行";
            } else if (value=='2'){
                str="<span style='color: red'>"+distName+"</span>" +" 执行中";
            } else if (value == '3'){
                str="待 "+ "<span style='color: red'>"+userName+"</span>" +" 验证";
            } else if (value == '4'){
                str="退回给"+ "<span style='color: red'>"+distName+"</span>";
            } else if (value == '5'){
                str="<span style='color: red'>已完成</span>";
            }
            $("#statusStr").html(str);

        });

        function submitForm() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-flow-add').serialize());
            }
        }
    </script>
</body>
</html>